package org.beanscreator;

import org.beanscreator.definitionreader.ClassDefinition;
import org.beanscreator.parsers.ParserTypes;
import org.beanscreator.definitionreader.XmlBeanDefinitionReader;
import org.beanscreator.definitionreader.XmlBeanDefinitionReaderImpl;

import java.util.List;

public class GenericXmlApplicationContextImpl implements GenericXmlApplicationContext {

    private final XmlBeanDefinitionReader reader = new XmlBeanDefinitionReaderImpl();
    private List<ClassDefinition> classDefsList;

    @Override
    public void setValidating(boolean validating) {
        reader.setValidating(validating);
    }

    @Override
    public void setParserType(ParserTypes parserType) {
        reader.setParserType(parserType);
    }

    @Override
    public void load(String xmlFileLocation) {
        reader.loadBeanDefinitions(xmlFileLocation);
        classDefsList = reader.getClassDefsList();
    }

    @Override
    public BeanFactory getBeanFactory() {

        return new BeanFactoryImpl(classDefsList);
    }
}
